package com.idis.dbApp.controller;

import com.idis.dbApp.mapper.IntroMapper;
import com.idis.entity.Intro;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Ming on 2018/1/30.
 */
@RestController
@RequestMapping("/intro")
@Api(tags = "简介接口")
public class IntroController {

    @Autowired
    IntroMapper introMapper;

    @ApiOperation("获取简介")
    @GetMapping("/all")
    public String findIntro(){
        return introMapper.findAll().get(0).getIntroduction();
    }

    @ApiOperation("更新简介")
    @PostMapping("/update")
    public Integer update(@ApiParam("简介内容")@RequestBody String introduction){
         Intro intro= introMapper.findAll().get(0);
         intro.setIntroduction(introduction);
         return introMapper.updateByPrimaryKey(intro);
    }

}
